import { IServiceManager } from "../../ioc/types";
import { AttachRequestArguments, LaunchRequestArguments } from "../types";
import { DebuggerBanner } from "./banner";
import { EQDebugConfigurationService } from "./configuration/debugConfigurationService";
import { FastAPILaunchDebugConfigurationProvider } from "./configuration/providers/fastapiLaunch";
import { FlaskLaunchDebugConfigurationProvider } from "./configuration/providers/flaskLaunch";
import { DebugConfigurationProviderFactory } from "./configuration/providers/providerFactory";
import { AttachConfigurationResolver } from "./configuration/resolvers/attach";
import { DebugEnvironmentVariablesHelper, IDebugEnvironmentVariablesService } from "./configuration/resolvers/helper";
import { LaunchConfigurationResolver } from "./configuration/resolvers/launch";
import { IDebugConfigurationProviderFactory, IDebugConfigurationResolver } from "./configuration/types";
import { ChildProcessAttachEventHandler } from "./hook/childProcessAttachHandler";
import { ChildProcessAttachService } from "./hook/childProcessAttachService";
import { IChildProcessAttachService, IDebugSessionEventHandlers } from "./hook/types";
import { DebugConfigurationType, IDebugConfigurationProvider, IDebugConfigurationService, IDebuggerBanner } from "./types";

export function registerTypes(serviceManager: IServiceManager) {
    serviceManager.addSingleton<IDebugSessionEventHandlers>(IDebugSessionEventHandlers, ChildProcessAttachEventHandler);
    serviceManager.addSingleton<IChildProcessAttachService>(IChildProcessAttachService, ChildProcessAttachService);
    serviceManager.addSingleton<IDebugConfigurationService>(
        IDebugConfigurationService,
        EQDebugConfigurationService,
    );
    serviceManager.addSingleton<IDebugConfigurationResolver<LaunchRequestArguments>>(
        IDebugConfigurationResolver,
        LaunchConfigurationResolver,
        'launch',
    );
    serviceManager.addSingleton<IDebugConfigurationResolver<AttachRequestArguments>>(
        IDebugConfigurationResolver,
        AttachConfigurationResolver,
        'attach',
    );
    serviceManager.addSingleton<IDebugEnvironmentVariablesService>(
        IDebugEnvironmentVariablesService,
        DebugEnvironmentVariablesHelper,
    );
    serviceManager.addSingleton<IDebugConfigurationProviderFactory>(
        IDebugConfigurationProviderFactory,
        DebugConfigurationProviderFactory,
    );
    serviceManager.addSingleton<IDebugConfigurationProvider>(
        IDebugConfigurationProvider,
        FastAPILaunchDebugConfigurationProvider,
        DebugConfigurationType.launchFastAPI,
    );
    serviceManager.addSingleton<IDebugConfigurationProvider>(
        IDebugConfigurationProvider,
        FlaskLaunchDebugConfigurationProvider,
        DebugConfigurationType.launchFlask,
    );
    serviceManager.addSingleton<IDebuggerBanner>(IDebuggerBanner, DebuggerBanner);
}